package org.rc.dto;

import lombok.Data;
import org.rc.entity.Sxzj;
import org.rc.entity.SxzjChannel;

import java.util.List;

@Data
public class SxzjDetailRes {
    private Long id;
    private String name;
    private String ip;
    private Integer port;
    private String userName;
    private String password;
    private List<Channel> channels;

    @Data
    public static class Channel{
        private Long id;
        private Long sxzjId;
        private String name;
        private Integer channelNo;
        private Integer rate;


        public static Channel getInstance(SxzjChannel sxzjChannel){
            Channel channel = new Channel();
            channel.setId(sxzjChannel.getId());
            channel.setName(sxzjChannel.getName());
            channel.setSxzjId(sxzjChannel.getSxzjId());
            channel.setChannelNo(sxzjChannel.getChannelNo());
            channel.setRate(sxzjChannel.getRate());
            return channel;
        }
    }

    public static SxzjDetailRes getInstance(Sxzj sxzj){
        SxzjDetailRes sxzjDetailRes = new SxzjDetailRes();
        sxzjDetailRes.setId(sxzj.getId());
        sxzjDetailRes.setName(sxzj.getName());
        sxzjDetailRes.setIp(sxzj.getIp());
        sxzjDetailRes.setPort(sxzj.getPort());
        sxzjDetailRes.setUserName(sxzj.getUserName());
        sxzjDetailRes.setPassword(sxzj.getPassword());
        return sxzjDetailRes;
    }
}
